package dao;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

import noNamespace.EcranDocument;
import noNamespace.EcranDocument.Ecran;

import org.apache.log4j.Logger;
import org.apache.xmlbeans.XmlOptions;

import constante.Constante;

public class ObjectLoader {
	public static Logger logger = Logger
			.getLogger(ObjectLoader.class.getName());

	public static Ecran loadEcran(String aPath) {
		Ecran lEcran = null;
		File xmlFile = null;
		Map<String, String> substNamespaces = null;
		XmlOptions xmlOps = null;
		xmlFile = new File(aPath);
		logger.debug("lecture du fichier :" + xmlFile.getAbsolutePath());
		substNamespaces = new HashMap<String, String>();
		substNamespaces.put("", Constante.XSDVERSION);
		xmlOps = new XmlOptions();
		xmlOps.setLoadSubstituteNamespaces(substNamespaces);
		try {
			lEcran = (EcranDocument.Factory.parse(xmlFile)).getEcran();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return lEcran;
	}
}
